package com.cqb.cn.controller;

import com.cqb.cn.common.utils.R;
import com.cqb.cn.mapper.CourseMapper;
import com.cqb.cn.modle.po.Course;
import com.cqb.cn.modle.po.Person;
import com.lkx.util.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @project_name: hqbz
 * @package_name: com.htsy.hqbz.controller
 * @ClassName: CourseController
 * @description: TODO
 * Author by cqb, Date on 2020/9/28，20:09
 * PS: Not easy to write code, please indicate.
 */
@Slf4j
@RestController
@RequestMapping("course")
public class CourseController {

    @Resource
    private CourseMapper courseMapper;

    @PostMapping(value = "/test")
    public R testImport(MultipartFile file) throws Exception{
        List<Person> list = ExcelUtil.readXls(file.getBytes(), Person.class);
        list.remove(0);
        return R.ok().data("personList",list);

    }
    @GetMapping(value = "getCourseById")
    public R getCourseById(Integer id){
        Course cc = courseMapper.selectByPrimaryKey(id);
        return R.ok().data(cc);
    }


}
